refactor(compile): reduce complexity of validate_github_issue_outputs_config - #2236
Closed
github-actions[bot] wants to merge 1 commit into
Closed
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…_config Splits the 135-line, cognitive-complexity-25 function into six focused helpers: - validate_create_github_issue_approval_lanes - validate_github_issue_shared_policy - validate_github_issue_tool_specific_config - validate_github_issue_tools - validate_create_github_issue_injection - validate_set_github_issue_type_injection validate_github_issue_outputs_config now just orchestrates these calls. No behaviour change; all existing tests pass unmodified. Highest remaining complexity among the extracted helpers is 13 (down from 25), and the orchestrator itself is no longer flagged even at a cognitive-complexity-threshold of 10. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This was referenced Sep 24, 2026
Collaborator
|
Integrated into #2238 as the canonical GitHub issue validation refactor and validated there. Closing this source PR as superseded by the aggregate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Refactors
validate_github_issue_outputs_configinsrc/compile/common.rs, which Clippy flagged at cognitive complexity 25 (threshold 15), the highest in the codebase.Why
The function mixed four unrelated concerns in one 135-line body: approval-lane checks, a per-tool loop with shared repo/mutation-filter policy validation, an 11-arm
matchdispatching to tool-specific validators, and two blocks of pipeline-injection checks. This made it hard to read, test in isolation, or extend with a new safe-output tool.Changes
Extracted six focused helper functions, each with a single responsibility:
validate_create_github_issue_approval_lanes— approval-lane parity checks for temporary-ID consumers.validate_github_issue_shared_policy— shared repository-policy and mutation-filter validation for one tool.validate_github_issue_tool_specific_config— the per-toolmatchdispatch.validate_github_issue_tools— loops over configured tools, calling the two helpers above.validate_create_github_issue_injection— pipeline-injection checks forcreate-github-issuefields.validate_set_github_issue_type_injection— pipeline-injection checks forset-github-issue-type.allowed.validate_github_issue_outputs_confignow just orchestrates these calls plus the final auth/permission lookups.Behaviour
No behavior change — this is a pure decomposition. Every branch, error message, and validation order is preserved exactly.
Verification
cargo test --bin ado-aw— all 3359 tests pass (0 failures), including all pre-existingvalidate_github_issue_outputs_config-related tests unmodified.cargo clippy --all-targets --all-features— clean, no warnings.cognitive-complexity-thresholdof 10 (previously 25 at threshold 15). The highest-complexity extracted helper (validate_github_issue_tool_specific_config, an 11-arm dispatch match) is 13.Before/after
validate_github_issue_outputs_configvalidate_github_issue_tool_specific_config)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.